import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SGuildPlayer } from "../../../../../Message/Game/SGuildPlayer";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { Cache } from "../../../cache/Cache";
import { AvatarType } from "../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { EGuildPosition } from "../../../../../Message/Game/EGuildPosition";
import { EVIPType } from "../../../../../Message/Public/EVIPType";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { CareerConfig } from "../../../resource/CareerConfig";
import { DateUtil } from "../../../../common/tools/DateUtil";
import { ClockManager } from "../../../manager/ClockManager";
import { Language } from "../../../../../extend/language/Language";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../../common/menu/PlayerOpRegister";
import { GTextFormat } from "../../../../common/GTextFormat";
import { ObjCreate } from "../../common/ObjCreate";
import { GuildVipItem } from "../GuildVipItem";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
type int = number;
//class MemberInfoRender
    
    export  class MemberInfoRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.mouseEnabled = true;
            this.mouseChildren = false;
            this.buttonMode = true;
            addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onMouseOut);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var arg0: Object;
            var imgName: string;
            var showColor: uint;

            var loc1;
            showColor = 0;
            arg0 = arg1;
            super.data = arg0;
            if (arg0 == null) 
            {
                return;
            }
            this.guildPlayer = arg0 as SGuildPlayer;
            this.miniPlayer = this.guildPlayer.miniPlayer;
            this._vip = this.miniPlayer.VIP;
            imgName = AvatarInfo.getPlayerAvatarName(Cache.instance.role.entityInfo.camp, this.miniPlayer.sex, AvatarType.FRIEND, this.miniPlayer.avatarId);
            with ({}) 
            {
            };
            imgName.load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onAvatarLoaded = (arg1: ImageInfo): void
            {
                avatarBitmap.bitmapData = arg1.bitmapData;
                avatarBitmap.width = 20;
                avatarBitmap.height = 20;
                return;
            })
            if (this.miniPlayer.online != 1) 
            {
                this.dealOnline(false);
            }
            else 
            {
                this.dealOnline(true);
                if (this.guildPlayer.position != EGuildPosition._EGuildLeader) 
                {
                    if (this.guildPlayer.position != EGuildPosition._EGuildDeputyLeader) 
                    {
                        if (this.guildPlayer.position != EGuildPosition._EGuildPresbyter) 
                        {
                            showColor = 16777215;
                        }
                        else 
                        {
                            showColor = 65280;
                        }
                    }
                    else 
                    {
                        showColor = 48895;
                    }
                }
                else 
                {
                    showColor = 16711935;
                }
                this.setTxtColor(showColor);
            }
            this.nameTxt.text = this.miniPlayer.name;
            this._vipItem.vip = this._vip;
            if (this._vip != EVIPType._EVIPTypeNormal) 
            {
                this._noVipTxt.visible = false;
            }
            else 
            {
                this._noVipTxt.visible = true;
            }
            this.positionTxt.text = GameDefConfig.instance.getPositionName(this.guildPlayer.position);
            this.levelTxt.text = this.miniPlayer.level.toString();
            this.careerTxt.text = CareerConfig.instance.getInfoByCode(this.miniPlayer.career).name;
            this.dayContriTxt.text = this.guildPlayer.contributionDay.toString();
            this.weekContriTxt.text = this.guildPlayer.contributionWeek.toString();
            this.totalContriTxt.text = this.guildPlayer.totalContribution.toString();
            if (this.miniPlayer.online != 1) 
            {
                this._downlineDays = (DateUtil.getTotalDays(ClockManager.instance.nowDate) - DateUtil.getTotalDays(this.guildPlayer.lastLogoutDt) - 1);
                if (this._downlineDays <= 0) 
                {
                    this.statusTxt.text = "——";
                }
                else if (this._downlineDays > 0 && this._downlineDays <= 7) 
                {
                    this.statusTxt.text = int(this._downlineDays) + Language.getString(57431);
                }
                else 
                {
                    this.statusTxt.text = Language.getString(57432);
                }
            }
            else 
            {
                this.statusTxt.text = Language.getString(57212);
            }
            if (this.playerMiniInfo == null) 
            {
                this.playerMiniInfo = new PlayerMiniInfo();
            }
            this.playerMiniInfo.miniPlayer = this.miniPlayer;
            PlayerOpRegister.Register(this, this.playerMiniInfo);
            return;
        }

        /* internal  */init(): void
        {
            var loc3=0;
            var loc1=11661567;
            var loc2=new GTextFormat();
            loc3 = 3;
            graphics.beginFill(16777215, 0);
            graphics.drawRect(0, 0, 625, 25);
            graphics.endFill();
            this.avatarBitmap = new Object /* flash.display.Bitmap */();
            this.avatarBitmap.x = 8;
            this.avatarBitmap.y = 0;
            addChild(this.avatarBitmap);
            this.nameTxt = ObjCreate.createTextField("", 35, 0, 35, 20, this);
            this.nameTxt.selectable = false;
            this.nameTxt.mouseEnabled = false;
            this.nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._vipItem = new GuildVipItem();
            this._vipItem.x = 125;
            this._vipItem.y = 3;
            this.addChild(this._vipItem);
            this._noVipTxt = ObjCreate.createTextField(Language.getString(30085), 125, 0, 220, 20, this, GlobalStyle.textFormat6);
            this.positionTxt = ObjCreate.createTextField("", 180, loc3, 35, 20, this);
            this.positionTxt.selectable = false;
            this.positionTxt.mouseEnabled = false;
            this.positionTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this.levelTxt = ObjCreate.createTextField("", 245, loc3, 35, 20, this);
            this.levelTxt.selectable = false;
            this.levelTxt.mouseEnabled = false;
            this.levelTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.careerTxt = ObjCreate.createTextField("", 300, loc3, 35, 20, this);
            this.careerTxt.selectable = false;
            this.careerTxt.mouseEnabled = false;
            this.careerTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this.dayContriTxt = ObjCreate.createTextField("", 340, loc3, 55, 20, this);
            this.dayContriTxt.mouseEnabled = false;
            this.dayContriTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.weekContriTxt = ObjCreate.createTextField("", 415, loc3, 65, 20, this);
            this.weekContriTxt.mouseEnabled = false;
            this.weekContriTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.totalContriTxt = ObjCreate.createTextField("", 485, loc3, 85, 20, this);
            this.totalContriTxt.mouseEnabled = false;
            this.totalContriTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.statusTxt = ObjCreate.createTextField("", 565, loc3, 85, 20, this);
            this.statusTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.statusTxt.mouseEnabled = false;
            this._overSkin = GlobalClass.getScaleBitmap(ImagesConst.Friend_over);
            this._overSkin.width = 600;
            this._overSkin.height = 25;
            this._overSkin.x = 35;
            ObjCreate.createBg(10, 25, 650, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */onMouseOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            addChildAt(this._overSkin, 0);
            return;
        }

        /* internal  */onMouseOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!_selected) 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                addChildAt(this._overSkin, 0);
                Cache.instance.guild.curSelGuildPlayer = this.guildPlayer;
            }
            else if (this._overSkin.parent) 
            {
                removeChild(this._overSkin);
            }
            return;
        }

        /* internal  */dealOnline(arg1: Boolean): void
        {
            var loc2=null;
            this.setTxtColor(11661311);
            var loc1=[this.avatarBitmap, this.nameTxt, this.positionTxt, this.levelTxt, this.careerTxt, this.dayContriTxt, this.weekContriTxt, this.totalContriTxt, this.statusTxt];
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                loc2 = loc1[loc3];
                loc2.filters = arg1 ? [] : [FilterConst.colorFilter];
                ++loc3;
            }
            return;
        }

        /* internal  */setTxtColor(arg1: uint): void
        {
            var loc2=null;
            var loc1=[this.nameTxt, this.positionTxt, this.levelTxt, this.careerTxt, this.dayContriTxt, this.weekContriTxt, this.totalContriTxt, this.statusTxt];
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                loc2 = loc1[loc3];
                loc2.textColor = arg1;
                ++loc3;
            }
            return;
        }

        /* internal */ /* var */avatarBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_vipItem: GuildVipItem;

        /* internal */ /* var */_noVipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */positionTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */careerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */dayContriTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */weekContriTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */totalContriTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */statusTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_overSkin: ScaleBitmap;

        /* internal */ /* var */guildPlayer: SGuildPlayer;

        /* internal */ /* var */playerMiniInfo: PlayerMiniInfo;

        /* internal */ /* var */miniPlayer: SPublicMiniPlayer;

        /* internal */ /* var */_vip: int;

        /* internal */ /* var */_downlineDays: number;
    }
